<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>管理员管理</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/style.css" />
<script src="__PUBLIC__/js/jquery.js" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/jquery.artDialog.js?skin=twitter" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/plugins/iframeTools.js" type="text/javascript"></script>
</head>
<body>
<div id="main">
    <form id="login-form" action="__URL__/edit" method="post">
        <input type="hidden" value="post" name="action" />
        <input type="hidden" value="{$info['admin_id']}" name="fid" />
        <table width="100%" class="table_form">
            <tr><th width="40">权限:</th><td><select name="group_id" class=":required">
                        <option value="">选择分类</option>
                        {loop $class $vo}
                        <option value="{$vo['group_id']}" {if $vo['id'] == $info['group_id']}selected="selected"{/if}>{$vo['name']}</option>
                        {/loop}
                    </select></td></tr>          
            <tr><th>用户:</th><td><input id="admin_user" type="text" name="admin_user" class="input-text" size="20" value="{$info['admin_user']}" {if $info['admin_id']}readonly="readonly"{/if} /><span class="hot">*</span></td></tr>
            <tr><th>密码:</th><td><input id="admin_pass" type="password" name="admin_pass" class="input-text" size="20" value="" /></td></tr>
            <tr><th>姓名:</th><td><input id="admin_name" type="text" name="admin_name"  class="input-text" size="10" value="{$info['admin_name']}" /><span class="hot">*</span></td></tr>
            <tr><th>锁定:</th><td><input type="radio" value="2" name="admin_lock" checked ="checked" /> 否&nbsp;&nbsp;<input type="radio" value="1" name="admin_lock"<?php if($info['admin_lock'] == 1) echo " checked =\" checked\""?> /> 是</td></tr>
            <tr><th>备注</th><td><textarea id="admin_text" name="admin_text" style="width: 400px;height: 50px">{$info['admin_text']}</textarea></td></tr>
        </table>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
    $(function () {
        var parent = art.dialog.parent,	// 父页面window对象
        api = art.dialog.open.api,//art.dialog.open扩展方法
        $ = function (id) {return document.getElementById(id)},
        form       = $('login-form'),
        admin_user = $('admin_user'),
        {if !$info['admin_id']}
admin_pass = $('admin_pass'),
        {/if}
admin_name = $('admin_name'),
        admin_text = $('admin_text')
        if (!api) return;
        api.title('添加/编辑')// 操作对话框
        .button({ // 自定义按钮
            name: '提交',
            callback: function () {
                if (check(admin_user){if !$info['admin_id']}&&check(admin_pass){/if}&&check(admin_name)&&check(admin_text)) form.submit();
                return false;
            },focus: true
        },{name: '取消'});
        // 表单验证
        var check = function (input) {
            if (input.value === '') {
                inputError(input);
                input.focus();
                return false;
            } else {
                return true;
            };
        };
        // 输入错误提示
        var inputError = function (input){
            clearTimeout(inputError.timer);
            var num = 0;
            var fn = function () {
                inputError.timer = setTimeout(function () {
                    input.className = input.className === '' ? 'login-form-error' : '';
                    if (num === 5) {
                        input.className === '';
                    } else {
                        fn(num ++);
                    };
                }, 150);
            };
            fn();
        };
        window.onload = function () {setTimeout(function () {username.focus()}, 240);};
    })();
</script>